package com.miracle9.game.dao;
import com.miracle9.game.entity.Admin;
import com.miracle9.game.entity.AdminLog;
import java.util.Map;
import org.apache.mina.core.session.IoSession;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

@Repository
public class AdminLogServiceDao extends SqlOperating<AdminLog, Integer>
{
  public AdminLog getLastLog(Admin admin)
  {
    IoSession session = (IoSession)com.miracle9.game.util.GameParameterAssist.be.get(Integer.valueOf(admin.getId()));
    Query query = q_CreateSql("from AdminLog where admin=? order by id desc", new Object[] { admin.getUsername() });
    if (session == null) {
      query.setFirstResult(1);
    }
    query.setMaxResults(1);
    return (AdminLog)query.uniqueResult();
  }
  
  public void addAdminLog(AdminLog adminLog)
  {
	  saveReturn(adminLog);
	  com.miracle9.game.util.GameParameterAssist.aL.put(adminLog.getAdmin(), adminLog);
  }
}
